package app.fugema.shop.main.setting.view;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.base.common.netBeanPackage.BaseApiResult;
import com.base.common.netBeanPackage.LiveDataWrapper;
import com.base.common.utils.UIUtils;
import com.base.common.view.base.BaseTitleActivity;
import com.base.common.view.base.OnGetDataListener;
import com.base.common.viewmodel.BaseViewObserver;
import app.fugema.shop.R;
import app.fugema.shop.databinding.ActivityAboutUsBinding;
import app.fugema.shop.main.setting.vm.SettingUserVM;

/**
 * 关于
 */
public class AboutActivity extends BaseTitleActivity<ActivityAboutUsBinding, SettingUserVM> implements OnGetDataListener {



    public static void start(Context context) {
        Intent intent = new Intent(context, AboutActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_us);
    }

    @Override
    protected void initView()
    {
        setCloseImg(R.mipmap.ic_back_white);
        setTitle("关于我们",R.color.white);
    }

    @Override
    protected int getStatusBarColor()
    {
        return R.color.redColor;
    }

    @Override
    protected void initData()
    {

        onGetData(1);
    }


    @Override
    public void onGetData(int pn)
    {
        viewModel.aboutUs().observe(this, new BaseViewObserver<LiveDataWrapper<BaseApiResult>>(viewUtils.getStateLayout()) {
            @Override
            protected void onSuccess(LiveDataWrapper<BaseApiResult> data)
            {
                // binding.reRichEditor.getNewContent(  )
                binding.reRichEditor.loadRichEditorCode( data.data.getMsg());
                binding.executePendingBindings();
            }
            @Override
            public boolean isEmptyData(LiveDataWrapper<BaseApiResult> data)
            {
                return  UIUtils.isEmpty(data.data.getMsg());
            }
        });

    }
}
